from django.shortcuts import render, HttpResponse
from blog.models import *


# Create your views here.

def bolg_modle_test(request):
	import datetime
	s = "hello"
	l = [111, 222, 333]  # 列表
	dic = {"name": "yuan", "age": 18}  # 字典
	date = datetime.date(1993, 5, 2)  # 日期对象

	class Person(object):
		def __init__(self, name):
			self.name = name

	person_yuan = Person("yuan")  # 自定义类对象
	person_egon = Person("egon")
	person_alex = Person("alex")

	person_list = [person_yuan, person_egon, person_alex]

	return render(request, "blog.html", {"l": l, "dic": dic, "date": date, "person_list": person_list})

def bolg_index(request):
	# 创建一条数据 方式一
	book_j = Book(title="PHP",
				  publish_data="2001-12-31",
				  author="第十一回",
				  price=100, )
	book_j.save()

	# 方式二
	# book_obj = Book.objects.create(title="PHP",
	# 							   publish_data="2001-12-31",
	# 							   author="我的天啊",
	# 							   price=100,
	# 							   )
	# print(book_obj.title)

	return render(request, "blog.html")
